home *** CD-ROM | disk | FTP | other *** search
/ Champak 122 / Vol 122.iso / games / sketchbo.swf / scripts / DefineSprite_161_mc_bomb / frame_1 / DoAction.as
Encoding:
Text File  |  2011-01-06  |  1.6 KB  |  85 lines

  1. ready = false;
  2. this.onEnterFrame = function()
  3. {
  4.    onFall();
  5.    this._x -= _hitomi.speed;
  6.    if(this.ready)
  7.    {
  8.       pushfactor = 10;
  9.       if(_hitomi.hitTest(this))
  10.       {
  11.          damage = random(30) + 12;
  12.          _hitomi.recieveHit(this);
  13.       }
  14.       var _loc3_ = 0;
  15.       while(_loc3_ < _root.pics_list.length)
  16.       {
  17.          damage = random(16) + 5;
  18.          var _loc5_ = _root.pics_list[_loc3_];
  19.          var _loc4_ = _loc5_.obj;
  20.          if(_loc4_.hitTest(this))
  21.          {
  22.             _loc4_.bombHit(damage,pushfactor);
  23.          }
  24.          _loc3_ = _loc3_ + 1;
  25.       }
  26.    }
  27. };
  28. init = function()
  29. {
  30.    gravity = 4;
  31.    time = getTimer();
  32.    time /= 100;
  33.    rot = random(21) - 10;
  34.    _rotation = 0;
  35.    floor = _parent.floor;
  36.    bounce = 0.22;
  37.    speedx = random(12) - 3;
  38.    speedystart = 0;
  39.    _init = true;
  40. };
  41. this.onFall = function()
  42. {
  43.    if(!_init)
  44.    {
  45.       init();
  46.    }
  47.    timenow = getTimer();
  48.    timenow /= 100;
  49.    speedy = gravity * (timenow - time) + speedystart;
  50.    this._x += speedx / 5;
  51.    this._y += speedy / 5;
  52.    if(this._y > floor)
  53.    {
  54.       this._y = floor;
  55.       speedy *= - bounce;
  56.       time = getTimer();
  57.       time /= 100;
  58.       rot *= -0.5;
  59.       speedystart = speedy;
  60.    }
  61.    if(speedy < 1 && _Y + 2 > floor)
  62.    {
  63.       speedx = 0;
  64.       this.onRotate = function()
  65.       {
  66.          if(_rotation % 360 > 180)
  67.          {
  68.          }
  69.          if(Math.abs(_rotation) < 2)
  70.          {
  71.             delete this.onRotate;
  72.          }
  73.       };
  74.    }
  75.    onRotate();
  76. };
  77. if(!_init)
  78. {
  79.    init();
  80. }
  81. playSound = function(ids)
  82. {
  83.    _root.sounds.playSound(ids);
  84. };
  85.